import java.util.Arrays;

public class Test03 {
    public static void main(String[] args) {
        //数组普通排序
        int[] array = {2, 1, 3, 6, 4, 5};
        for (int i = 0; i < array.length; i++) {
            for (int j = 0; j < array.length - i - 1; j++) {
                if (array[j] > array[j + 1]) {
                    int temp = array[j];
                    array[j] = array[j + 1];
                    array[j + 1] = temp;
                }
            }
        }
        System.out.println(Arrays.toString(array));

        //数组冒泡排序
        int[] array1 = {2, 1, 3, 6, 4, 5, 9, 8, 0};
        for (int i = 0; i < array1.length; i++) {
            for (int j = 0; j < array1.length - i - 1; j++) {
                if (array1[j] > array1[j + 1]) {
                    int temp = array1[j];
                    array1[j] = array1[j + 1];
                    array1[j + 1] = temp;
                }
            }
        }
        System.out.println(Arrays.toString(array1));

        //数组倒序
        //用Arrays.sort()方法实现数组倒序
        int[] array2 = {2, 1, 3, 6, 4, 5, 9, 8, 0};
        Arrays.sort(array2);
        for (int i = 0; i < array2.length / 2; i++) {
            int temp = array2[i];
            array2[i] = array2[array2.length - i - 1];
            array2[array2.length - i - 1] = temp;
        }
        System.out.println(Arrays.toString(array2));


    }

}